<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
    x:Class="OpenLS.Chart.UI.CategoryAxisResources"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:chart="http://schemas.Kherty.com/office/2007/chart"
    xmlns:chartui="clr-namespace:OpenLS.Chart.UI"
    xmlns:Internals="clr-namespace:OpenLS.Chart.UI.Internals"
    xmlns:drawingui="clr-namespace:OpenLS.Drawing.UI;assembly=OpenLS.Drawing.UI">
    <ResourceDictionary.MergedDictionaries>
        <chartui:ValueResources />
        <drawingui:TextResources></drawingui:TextResources>
    </ResourceDictionary.MergedDictionaries>
    <DataTemplate DataType="{x:Type chart:Axis}" x:Key="forceCategory">
        <!-- obsolete -->
        <ItemsControl  
                    Style ="{Binding Path=Style}" Name="categoryAxis" MouseDown="onMouseDown"
                       chartui:AxisElement.Axis="{Binding}">
            <ItemsControl.ItemsSource>
                <MultiBinding>
                    <MultiBinding.Converter>
                        <chartui:FilteredCollectionFactory/>
                    </MultiBinding.Converter>
                    <Binding Path="(chartui:AxisElement.ItemsSource)" RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="TickLabelSkip"/>
                    <Binding Path="(chartui:AxisElement.ItemsSource)" RelativeSource="{RelativeSource Self}"/>
                </MultiBinding>
            </ItemsControl.ItemsSource>
            <ItemsControl.CommandBindings>
                <CommandBinding Command="{x:Static chartui:ChartCommands.FormatAxis}" Executed="onFormatAxis"/>
                <CommandBinding Command="{x:Static ApplicationCommands.Delete}" Executed="onDeleteAxis"/>
                <CommandBinding Command="{x:Static chartui:ChartCommands.AddTitle}" Executed="onAddTitle" CanExecute="onCanAddTitle" />
            </ItemsControl.CommandBindings>
            <ItemsControl.ContextMenu>
                <ContextMenu>
                    <MenuItem Command="{x:Static ApplicationCommands.Delete}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                    <MenuItem Command="{x:Static chartui:ChartCommands.AddTitle}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                    <MenuItem Command="{x:Static chartui:ChartCommands.FormatAxis}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                </ContextMenu>
            </ItemsControl.ContextMenu>

            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Internals:CategoryAxisPanel DataContext="{Binding}" 
                                       Orientation="{Binding Path=(chartui:AxisElement.Orientation), RelativeSource={RelativeSource Self}}" 
                                       CategoryAxisOrientation="{Binding Orientation}"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemContainerStyle>
                <Style>
                    <Setter Property="Internals:CategoryAxisPanel.Index" Value="{Binding Index}"/>
                    <Setter Property="FrameworkElement.LayoutTransform">
                        <Setter.Value>
                            <RotateTransform Angle="0"/>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ItemsControl.ItemContainerStyle>
        </ItemsControl>

    </DataTemplate>
    <DataTemplate DataType="{x:Type chart:CategoryAxis}" >
        <DockPanel Name="categoryAxisPanel" chartui:AxisElement.Axis="{Binding}" >
            <Line Name="line" Style="{x:Static chartui:ShapedObjectResources.ShapedObjectStyle}" StrokeThickness="{Binding ShapeProperties.LineProperties.Width, FallbackValue=1}"></Line>

            <Grid Name="title" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Grid.CommandBindings>
                    <CommandBinding Command="{x:Static ApplicationCommands.Delete}" Executed="onDeleteTitle"></CommandBinding>
                </Grid.CommandBindings>
                <ContentPresenter  Content="{Binding Title.Text.Content}" 
                               HorizontalAlignment="Center" VerticalAlignment="Center"
                               >
                </ContentPresenter>

            </Grid>
            <ItemsControl  
                    Style ="{Binding Path=Style}" Name="categoryAxis" MouseDown="onMouseDown"
                       chartui:AxisElement.Axis="{Binding}">
                <ItemsControl.ItemsSource>
                    <MultiBinding>
                        <MultiBinding.Converter>
                            <chartui:FilteredCollectionFactory/>
                        </MultiBinding.Converter>
                        <Binding Path="(chartui:AxisElement.ItemsSource)" RelativeSource="{RelativeSource Self}"/>
                        <Binding Path="TickLabelSkip"/>
                    </MultiBinding>
                </ItemsControl.ItemsSource>

                <ItemsControl.CommandBindings>
                    <CommandBinding Command="{x:Static chartui:ChartCommands.FormatAxis}" Executed="onFormatAxis"/>
                    <CommandBinding Command="{x:Static ApplicationCommands.Delete}" Executed="onDeleteAxis"/>
                    <CommandBinding Command="{x:Static chartui:ChartCommands.AddTitle}" Executed="onAddTitle" CanExecute="onCanAddTitle"/>
                </ItemsControl.CommandBindings>
                <ItemsControl.ContextMenu>
                    <ContextMenu>
                        <MenuItem Command="{x:Static ApplicationCommands.Delete}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                        <MenuItem Command="{x:Static chartui:ChartCommands.AddTitle}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                        <MenuItem Command="{x:Static chartui:ChartCommands.FormatAxis}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path= (chartui:AxisElement.Axis)}"/>
                    </ContextMenu>
                </ItemsControl.ContextMenu>

                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Internals:CategoryAxisPanel DataContext="{Binding}" Maximum="{Binding Path=(chartui:AxisElement.Maximum), RelativeSource={RelativeSource Self}}"
                                       Orientation="{Binding Path=(chartui:AxisElement.Orientation), RelativeSource={RelativeSource Self}}" 
                                       CategoryAxisOrientation="{Binding Orientation}"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemContainerStyle>
                    <Style>
                        <Setter Property="Internals:CategoryAxisPanel.Index" Value="{Binding Index}"/>
                        <Setter Property="FrameworkElement.LayoutTransform">
                            <Setter.Value>
                                <RotateTransform Angle="0"/>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ItemsControl.ItemContainerStyle>
            </ItemsControl>
        </DockPanel>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Position}" Value="Top">
                <Setter TargetName="line" Property="DockPanel.Dock" Value="Bottom"/>
                <Setter TargetName="line" Property="X2" Value="{Binding ElementName=grid, Path=ActualWidth}"/>
                <Setter TargetName="title" Property="DockPanel.Dock" Value="Top"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Position}" Value="Bottom">
                <Setter TargetName="line" Property="DockPanel.Dock" Value="Top"/>
                <Setter TargetName="title" Property="DockPanel.Dock" Value="Bottom"/>
                <Setter TargetName="line" Property="X2" Value="{Binding ElementName=grid, Path=ActualWidth}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Position}" Value="Left">
                <Setter TargetName="line" Property="DockPanel.Dock" Value="Right"/>
                <Setter TargetName="title" Property="DockPanel.Dock" Value="Left"/>
                <Setter TargetName="line" Property="Y2" Value="{Binding ElementName=grid, Path=ActualHeight}"/>
                <Setter TargetName="line" Property="Grid.Column" Value="1"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Position}" Value="Right">
                <Setter TargetName="line" Property="DockPanel.Dock" Value="Left"/>
                <Setter TargetName="title" Property="DockPanel.Dock" Value="Right"/>
                <Setter TargetName="line" Property="Y2" Value="{Binding ElementName=grid, Path=ActualHeight}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding IsVisible}" Value="False">
                <Setter TargetName="categoryAxisPanel" Property="Visibility" Value="Collapsed"></Setter>
            </DataTrigger>
        </DataTemplate.Triggers>

    </DataTemplate>

</ResourceDictionary>